<template>
	<view class="tabbar-container">
		<block>
			<view class="tabbar-item" v-for="(item, index) in tabbarList" :key="index" :class="[item.centerItem ? ' center-item' : '']" @click="changeItem(item)">
				<view class="item-top"><image :src="currentItem == item.id ? item.selectIcon : item.icon"></image></view>
				<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
					<text>{{ item.text }}</text>
				</view>
			</view>
		</block>
	</view>
</template>
 
<script>
export default {
	props: {
		currentPage: {
			type: Number,
			default: 0
		}
	},
	data() {
		return {
			currentItem: 0,
			tabbarList: [
				{
					id: 0,
					path: '/pages/index/index',
					icon: '/static/ico_1.png',
					selectIcon: '/static/ico_1h.png',
					text: '工作台',
					centerItem: false
				},
				{
					id: 1,
					// path: '/pages/code/code',
					icon: '/static/tab_center.png',
					selectIcon: '/static/tab_center.png',
					text: '核销',
					centerItem: true
				},
				{
					id: 2,
					path: '/pages/user/user',
					icon: '/static/ico_2.png',
					selectIcon: '/static/ico_2h.png',
					text: '我的',
					centerItem: false
				},
			]
		};
	},
	mounted() {
		this.currentItem = this.currentPage;
		uni.hideTabBar();
	},
	methods: {
		changeItem(item) {
			let _this = this;
			//_this.currentItem = item.id;
			if(item.id == 1){
				uni.navigateTo({
					url: '/pages/scan/scan_index'
				})
			}else{
				uni.switchTab({
					url: item.path
				});
			}
			
		}
	}
};
</script>
<style>
.tabbar-container {
	position: fixed;
	bottom: 0rpx;
	left: 0;
	width: 100%;
	display: flex;
	align-items: center;
	padding-top: 20rpx;
	padding-bottom: 30rpx;
	color: #333333;
	z-index: 9999;
	background-color: #ffffff;
}
.tabbar-container .tabbar-item {
	width: 33%;
	height: 100rpx;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
}
.tabbar-container .item-active {
	color: #3274F9;
}
.tabbar-container .center-item {
	display: block;
	position: relative;
}
.tabbar-container .tabbar-item .item-top {
	width: 50rpx;
	height: 50rpx;
	/* padding: 10rpx; */
}
.tabbar-container .center-item .item-top {
	flex-shrink: 0;
	width: 90rpx;
	height: 90rpx;
	position: absolute;
	top: -50rpx;
	left: calc(50% - 45rpx);
	border-radius: 50%;
	box-shadow: 0 0 5px #999;
	background-color: #ffffff;
}
.tabbar-container .tabbar-item .item-top image {
	width: 100%;
	height: 100%;
}
.tabbar-container .tabbar-item .item-bottom {
	font-size: 28rpx;
	width: 100%;
}
.tabbar-container .center-item .item-bottom {
	position: absolute;
	bottom: 5rpx;
}
</style>
